Add time data source format style support#889
Conversation
🤖 Augment PR SummarySummary: This PR adds infrastructure for time-based discrete format styles so Changes:
Technical Notes: The new storage resolves format styles using environment locale/calendar/time zone and derives an update-frequency budget based on interface idiom (widget/complication/etc.), with placeholders for future scheduling/serialization work. 🤖 Was this summary useful? React with 👍 or 👎 |
| return format.format(value).attributedString | ||
| } | ||
|
|
||
| var schedule: Schedule? { |
There was a problem hiding this comment.
Sources/OpenSwiftUICore/View/Text/FormatStyle/TimeDataFormatting.swift:106: schedule currently returns nil (and entries returns an empty sequence), which makes ResolvableStringAttribute.isDynamic false so time-based Text won’t auto-update over time. Was the intent to return a non-nil schedule here to drive timeline invalidation?
Severity: high
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| NSAttributedString.Key("OpenSwiftUITimeDataFormatting") | ||
| } | ||
|
|
||
| static func decode(from decoder: any Decoder) throws -> (any ResolvableStringAttribute)? { |
There was a problem hiding this comment.
Sources/OpenSwiftUICore/View/Text/FormatStyle/TimeDataFormatting.swift:19: decode(from:) always returns nil (and encode is a no-op), so TimeDataFormatting attributes can’t round-trip through archiving/serialization and may be dropped. If this is meant to support “safe serialization”, it likely needs an actual implementation.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #889 +/- ##
==========================================
- Coverage 26.73% 26.52% -0.22%
==========================================
Files 686 689 +3
Lines 47796 48193 +397
==========================================
+ Hits 12778 12781 +3
- Misses 35018 35412 +394 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2ec9bdc to
747aeea
Compare
| guard let other = other as? TimeDataFormattingStorage<Source, Format> else { | ||
| return false | ||
| } | ||
| return source == other.source && format == other.format |
There was a problem hiding this comment.
Sources/OpenSwiftUICore/View/Text/FormatStyle/Text+DiscreteFormatStyle.swift:687: TimeDataFormattingStorage.isEqual(to:) ignores reducedLuminanceBudget, but that value changes the computed secondsUpdateFrequencyBudget (and potentially formatting behavior) in resolve. This could cause two storages with different reduced-luminance behavior to compare equal and lead to stale rendering/caching decisions.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Agent Summary
This PR adds time-based discrete format style support for text rendering.
TimeDataSourcesupport for current dates, duration offsets, and date ranges.TextandLocalizedStringKey.StringInterpolationoverloads for discrete time-based format styles.TimeDataFormattingstorage and resolution plumbing for live text updates.Testing
git diff --checkswiftc -typecheck Sources/OpenSwiftUICore/View/Text/FormatStyle/TimeZoneDependentFormatStyle.swiftssh ubuntu@orb 'cd /Volumes/Workspace/OpenSwiftUI-Mono/Worktrees/feature_format_style/OpenSwiftUI && export OPENSWIFTUI_LIB_SWIFT_PATH="$(swiftly use --print-location)/usr/lib/swift" && swift build --jobs 1'\n